package gameEngine.agents.choosingStrategy;

import gameEngine.agents.teamMateModel.AgentMock;
import gameEngine.agents.teamMateModel.TeamMateModel;

import java.util.ArrayList;
import java.util.Collections;

import org.apache.log4j.Logger;

/**
 * choose best strategy
 * @author alon
 *
 */
public class GreedyStrategy implements ChoosingStrategy {
	Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * sort agents by competence and return best's id
	 */
	public int chooseNextPlayer(TeamMateModel teamMateModel) {
		ArrayList<AgentMock> agents=new ArrayList<AgentMock>();
		agents.addAll(teamMateModel.getTeamMates());
		//sorts in descending order
		Collections.sort(agents);
		int agent=agents.get(0).getId();
		log.debug("best agent is agent "+agent);
		return agent;
	}
	
	public GreedyStrategy clone(){
		return new GreedyStrategy();
	}
}
